/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.leader
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-5-7
 * @time 下午1:25:45
 */
package com.ssh.web.leader;

import java.util.List;

import com.ssh.entity.AskForleave;
import com.ssh.model.pdata.AskForLeaveMData;
import com.ssh.ser.common.AskForLeaveSerI;

/**
 * @author jack
 * @desc 请假申请处理
 */
public class DealAskForLeaveAction {
	private List<AskForLeaveMData> askForLeaveMDataList;
	private AskForLeaveSerI askForLeaveSerI;
	private String staffId;
	private String idWhoAskForLeave;
	private String idaskForleave;

	/**
	 * @return the idaskForleave
	 */
	public String getIdaskForleave() {
		return idaskForleave;
	}

	/**
	 * @param idaskForleave the idaskForleave to set
	 */
	public void setIdaskForleave(String idaskForleave) {
		this.idaskForleave = idaskForleave;
	}

	public String agree() {
		try {
			int id = Integer.parseInt(idaskForleave);
			AskForleave askForleave=askForLeaveSerI.viewAskForLeaveById(id);
			askForleave.setState(1);
			askForLeaveSerI.agreeAskForLeave(askForleave);
			return "agree";
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}

	public String disAgree() {
		try {
			int id = Integer.parseInt(idaskForleave);
			AskForleave askForleave=askForLeaveSerI.viewAskForLeaveById(id);
			askForleave.setState(2);
			askForLeaveSerI.disAgreeAskForLeave(askForleave);
			return "disAgree";
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}

	/**
	 * @return the askForLeaveMDataList
	 */
	public List<AskForLeaveMData> getAskForLeaveMDataList() {
		return askForLeaveMDataList;
	}

	/**
	 * @return the askForLeaveSerI
	 */
	public AskForLeaveSerI getAskForLeaveSerI() {
		return askForLeaveSerI;
	}

	/**
	 * @return the staffId
	 */
	public String getStaffId() {
		return staffId;
	}

	/**
	 * @param askForLeaveMDataList the askForLeaveMDataList to set
	 */
	public void setAskForLeaveMDataList(List<AskForLeaveMData> askForLeaveMDataList) {
		this.askForLeaveMDataList = askForLeaveMDataList;
	}

	/**
	 * @param askForLeaveSerI the askForLeaveSerI to set
	 */
	public void setAskForLeaveSerI(AskForLeaveSerI askForLeaveSerI) {
		this.askForLeaveSerI = askForLeaveSerI;
	}

	/**
	 * @param staffId
	 *            the staffId to set
	 */
	public void setStaffId(String staffId) {
		this.staffId = staffId;
	}

	public String viewWhoWtoAFL() {
		try {
			askForLeaveMDataList = askForLeaveSerI.viewAllAskForLeave(0);
			return "viewWhoWantoAFL";
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}

	/**
	 * @return the idWhoAskForLeave
	 */
	public String getIdWhoAskForLeave() {
		return idWhoAskForLeave;
	}

	/**
	 * @param idWhoAskForLeave the idWhoAskForLeave to set
	 */
	public void setIdWhoAskForLeave(String idWhoAskForLeave) {
		this.idWhoAskForLeave = idWhoAskForLeave;
	}

}
